#pragma once
#include <QSharedPointer>
#include <iostream>
#include <unordered_set>
#include <array>
#include <string>
using namespace std;

typedef struct ST_QSOCKETCLIENT_OBJ {
	void* hSocketClient;
	int type;
	long id;
	ST_QSOCKETCLIENT_OBJ(const ST_QSOCKETCLIENT_OBJ& a) {
		this->hSocketClient = a.hSocketClient;
		this->type = a.type;
		this->id = a.id;
	}

	ST_QSOCKETCLIENT_OBJ& operator= (const ST_QSOCKETCLIENT_OBJ& a) {
		this->hSocketClient = a.hSocketClient;
		this->type = a.type;
		this->id = a.id;
		return *this;
	}
	ST_QSOCKETCLIENT_OBJ()
	{
		this->hSocketClient = nullptr;
		this->type = -1;
		this->id = -1;
	}
	ST_QSOCKETCLIENT_OBJ(void* hSocketClient, int type, int id)
	{
		this->hSocketClient = hSocketClient;
		this->type = type;
		this->id = id;
	}
	bool operator == (const ST_QSOCKETCLIENT_OBJ& t) const {
		return  t.hSocketClient == hSocketClient && t.id == id;
	}
	bool operator != (const ST_QSOCKETCLIENT_OBJ& t) const {
		return  t.hSocketClient != hSocketClient || t.id != id;
	}
}QSOCKETCLIENT;
struct SocketClientHash {
	std::size_t operator () (const QSOCKETCLIENT& t) const {
		return ((size_t)t.hSocketClient) % 600;
	}
};
class QSocketClientManager
{
private:
	unordered_set<QSOCKETCLIENT, SocketClientHash> m_setHSocketClients;
public:
	bool PushSocketClient(QSOCKETCLIENT pSocketClient);
	bool RemoveSocketClient(QSOCKETCLIENT pSocketClient);
	bool FindSocketClient(QSOCKETCLIENT pSocketClient);
	void ClearSocketClient();
};
bool AcceptSocketClient(QSOCKETCLIENT pSocketClient);
bool ExistsSocketClient(QSOCKETCLIENT pSocketClient);
bool CloseSocketClient(QSOCKETCLIENT& pSocketClient);
void ClearSocketClient();

